package cn.demarcia.coco;

import android.app.Application;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.baidu.mapapi.SDKInitializer;
import com.facebook.drawee.backends.pipeline.Fresco;

import info.jimao.newsdk.ApiManager;

/**
 * Created by 智尧
 * on 2016/7/19.
 */
public class AppContext extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        //初始化API管理器
        ApiManager.getInstance()
                .initialize(this, AppConfig.SERVER_API);
        //初始化Fresco
        Fresco.initialize(this);
        //初始化百度SDK
        SDKInitializer.initialize(getApplicationContext());
    }

    public boolean isNetworkConnected() {
        ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo ni = cm.getActiveNetworkInfo();
        return ni != null && ni.isConnectedOrConnecting();
    }
}
